/*
 DNN Content Builder - sourceforge.net/projects/dnncb
 Copyright (c) 2004-2007
 by Emerson Lopes (emersonlopes@gmail.com)

 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
 documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
 to permit persons to whom the Software is furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all copies or substantial portions 
 of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 DEALINGS IN THE SOFTWARE.
*/

// DotNetNuke Visual C# source code for cbContentBuilder data provider SqlDataProvider, generated sexta-feira, 8 de outubro de 2004 at 21:30:44
// Generated by DotNetNuke DAL Builder 2 from www.dotnetnuke.dk version 2.1.1714.41920

using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace DNNContentBuilder 
{
    
	public class SqlDataProvider : DNNContentBuilder.DataProvider 
	{
		#region Member Variables
		private const string providerType = "data";

		private DotNetNuke.Framework.Providers.ProviderConfiguration mProviderConfiguration = DotNetNuke.Framework.Providers.ProviderConfiguration.GetProviderConfiguration(providerType);
		private string mConnectionString;
		private string mProviderPath;
		private string mObjectQualifier;
		private string mDatabaseOwner;
		#endregion
        
		#region Constructors
		public SqlDataProvider() 
		{
			DotNetNuke.Framework.Providers.Provider provider = (DotNetNuke.Framework.Providers.Provider)mProviderConfiguration.Providers[mProviderConfiguration.DefaultProvider];

			mConnectionString = System.Configuration.ConfigurationSettings.AppSettings[provider.Attributes["connectionStringName"]]; 
			
			mProviderPath = provider.Attributes["providerPath"];
			mObjectQualifier = provider.Attributes["objectQualifier"];
 
			if ((mObjectQualifier!="") && (!mObjectQualifier.EndsWith("_"))) 
			{
				mObjectQualifier += "_";
			}

			mDatabaseOwner = provider.Attributes["databaseOwner"];
			
			if ((mDatabaseOwner!="") && (!mDatabaseOwner.EndsWith("."))) 
			{
				mDatabaseOwner += ".";
			}
		}
		#endregion

		#region Properties
		public string ConnectionString 
		{
			get { return mConnectionString; }
		}
        
		public string ProviderPath 
		{
			get { return mProviderPath; }
		}
        
		public string ObjectQualifier 
		{
			get { return mObjectQualifier; }
		}
        
		public string DatabaseOwner 
		{
			get { return mDatabaseOwner; }
		}
		#endregion
        
		#region Implementation

		#region Helper Methods
		public object GetNull(object field) 
		{
			return DotNetNuke.Common.Utilities.Null.GetNull(field, DBNull.Value);
		}
        
		public object ExecuteScalar(string spName, params object[] parameterValues)
		{
			// Transactional mode
			if (this.ConnectionProvider != null && this.ConnectionProvider.DBTransaction != null)
			{
				return SqlHelper.ExecuteScalar((SqlTransaction)ConnectionProvider.DBTransaction, spName, parameterValues);
			}
				
			// Non-transactional mode
			return SqlHelper.ExecuteScalar(ConnectionProvider.ConnectionString, spName, parameterValues);
		}

		public IDataReader ExecuteReader(string spName, params object[] parameterValues)
		{
			// Transactional mode
			if (this.ConnectionProvider != null && this.ConnectionProvider.DBTransaction != null)
			{
				return SqlHelper.ExecuteReader((SqlTransaction)ConnectionProvider.DBTransaction, spName, parameterValues);
			}
				
			// Non-transactional mode
			return SqlHelper.ExecuteReader(ConnectionProvider.ConnectionString, spName, parameterValues);
		}

		public void ExecuteNonQuery(string spName, params object[] parameterValues)
		{
			// Transactional mode
			if (this.ConnectionProvider != null && this.ConnectionProvider.DBTransaction != null)
			{
				SqlHelper.ExecuteNonQuery((SqlTransaction)ConnectionProvider.DBTransaction, spName, parameterValues);
			}
			else
			{
				// Non-transactional mode
				SqlHelper.ExecuteNonQuery(ConnectionProvider.ConnectionString, spName, parameterValues);
			}
		}
		#endregion

		#region Data access methods implementation for cbDatabase

		public override IDataReader DatabaseGetAllDatabases() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbDatabaseGetAllDatabases");
		}

		public override IDataReader DatabaseGet(Int32 databaseId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbDatabaseGet", databaseId);
		}
		#endregion

		#region Data Access methods implementation for cbConnectionString
        
		public override Int32 ConnectionStringAdd(string title, Int32 databaseId, string connectionString) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbConnectionStringAdd", title, databaseId, connectionString));
		}
        
		public override void ConnectionStringUpdate(Int32 connectionStringId, string title, Int32 databaseId, string connectionString) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbConnectionStringUpdate", connectionStringId, title, databaseId, connectionString);
		}
        
		public override void ConnectionStringDelete(Int32 connectionStringId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbConnectionStringDelete", connectionStringId);
		}
        
		public override IDataReader ConnectionStringGet(Int32 connectionStringId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbConnectionStringGet", connectionStringId);
		}

		public override IDataReader ConnectionStringGetByTitle(string connectionTitle) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbConnectionStringGetByTitle", connectionTitle);
		}
        
		public override IDataReader ConnectionStringGetAllConnections() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbConnectionStringGetAllConnections");
		}
		#endregion
        
		#region Data Access methods implementation for cbContentManagerSettings
        
		public override Int32 ContentManagerSettingsAdd(Int32 formDefinitionId, Int32 workflowId, Int32 moduleID) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbContentManagerSettingsAdd", formDefinitionId, workflowId, moduleID));
		}
        
		public override void ContentManagerSettingsUpdate(Int32 contentManagerSettingsId, Int32 formDefinitionId, Int32 workflowId, Int32 moduleID) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbContentManagerSettingsUpdate", contentManagerSettingsId, formDefinitionId, workflowId, moduleID);
		}
        
		public override void ContentManagerSettingsDelete(Int32 contentManagerSettingsId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbContentManagerSettingsDelete", contentManagerSettingsId);
		}
        
		public override IDataReader ContentManagerSettingsGet(Int32 contentManagerSettingsId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentManagerSettingsGet", contentManagerSettingsId);
		}
        
		public override IDataReader ContentManagerSettingsByFormDefinition(Int32 formDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentManagerSettingsByFormDefinition", formDefinitionId);
		}
        
		public override IDataReader ContentManagerSettingsByWorkflow(Int32 workflowId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentManagerSettingsByWorkflow", workflowId);
		}
        
		public override IDataReader ContentManagerSettingsByModules(Int32 moduleID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentManagerSettingsByModules", moduleID);
		}
		#endregion
        
		#region Data Access methods implementation for cbContentSecurity
        
		public override Int32 ContentSecurityAdd(Int32 metaDataId, string contentAuthorizedViewer) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbContentSecurityAdd", metaDataId, contentAuthorizedViewer));
		}
        
		public override void ContentSecurityUpdate(Int32 contentSecurityId, Int32 metaDataId, string contentAuthorizedViewer) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbContentSecurityUpdate", contentSecurityId, metaDataId, GetNull(contentAuthorizedViewer));
		}
        
		public override void ContentSecurityDelete(Int32 contentSecurityId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbContentSecurityDelete", contentSecurityId);
		}
        
		public override IDataReader ContentSecurityGet(Int32 contentSecurityId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentSecurityGet", contentSecurityId);
		}
        
		public override IDataReader ContentSecurityByMetaData(Int32 metaDataId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentSecurityByMetaData", metaDataId);
		}
		#endregion
        
		#region Data Access methods implementation for cbContentViewerSettings
        
		public override Int32 ContentViewerSettingsAdd(Int32 moduleID, Int32 templateDefinitionId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbContentViewerSettingsAdd", moduleID, templateDefinitionId));
		}
        
		public override void ContentViewerSettingsUpdate(Int32 contentViewerSettingsId, Int32 moduleID, Int32 templateDefinitionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbContentViewerSettingsUpdate", contentViewerSettingsId, moduleID, templateDefinitionId);
		}
        
		public override void ContentViewerSettingsDelete(Int32 contentViewerSettingsId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbContentViewerSettingsDelete", contentViewerSettingsId);
		}
        
		public override IDataReader ContentViewerSettingsGet(Int32 contentViewerSettingsId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentViewerSettingsGet", contentViewerSettingsId);
		}
        
		public override IDataReader ContentViewerSettingsByTemplateDefinition(Int32 templateDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentViewerSettingsByTemplateDefinition", templateDefinitionId);
		}
        
		public override IDataReader ContentViewerSettingsByModules(Int32 moduleID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbContentViewerSettingsByModules", moduleID);
		}
		#endregion
        
		#region Data Access methods implementation for cbControlType
        
		public override Int32 ControlTypeAdd(string title, string controlPath, string typeName, string assemblyName, string nameSpace) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbControlTypeAdd", title, GetNull(controlPath), typeName, GetNull(assemblyName), nameSpace));
		}
        
		public override void ControlTypeUpdate(Int32 controlTypeId, string title, string controlPath, string typeName, string assemblyName, string nameSpace) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbControlTypeUpdate", controlTypeId, title, GetNull(controlPath), typeName, GetNull(assemblyName), nameSpace);
		}
        
		public override void ControlTypeDelete(Int32 controlTypeId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbControlTypeDelete", controlTypeId);
		}
        
		public override IDataReader ControlTypeGet(Int32 controlTypeId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbControlTypeGet", controlTypeId);
		}

		public override IDataReader ControlTypeGetItemByPath(string path) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbControlTypeGetItemByPath", path);
		}

		public override IDataReader ControlTypeGetAllControlType() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbControlTypeGetAllControlType");
		}
		#endregion
        
		#region Data Access methods implementation for cbDataConnection
        
		public override void DataConnectionAdd(string tableName, Int32 connectionStringId, string primaryKeyName) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbDataConnectionAdd", tableName, connectionStringId, primaryKeyName);
		}
        
		public override void DataConnectionUpdate(Int32 dataConnectionId, string tableName, Int32 connectionStringId, string primaryKeyName) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbDataConnectionUpdate", dataConnectionId, tableName, connectionStringId, primaryKeyName);
		}
        
		public override void DataConnectionDelete(Int32 dataConnectionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbDataConnectionDelete", dataConnectionId);
		}
        
		public override IDataReader DataConnectionGet(Int32 dataConnectionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbDataConnectionGet", dataConnectionId);
		}
        
		public override IDataReader DataConnectionByConnectionString(Int32 connectionStringId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbDataConnectionByConnectionString", connectionStringId);
		}
        
		public override IDataReader DataConnectionGetAllDataConnections() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbDataConnectionGetAllDataConnections");
		}

		public override IDataReader DataConnectionGetByTableName(string tableName) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbDataConnectionGetDataConnectionByTableName", tableName);
		}
		#endregion

		#region Data Access methods implementation for cbFieldDefinition
        
		public override Int32 FieldDefinitionAdd(string title, string cssClass, bool search, string tooltip, bool required, string sourceField, Int32 formDefinitionId, Int32 controlTypeId, int tabIndex, string XML, bool visible, bool isTitle, Int32 dataConnectionId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionAdd", title, GetNull(cssClass), search, GetNull(tooltip), required, sourceField, formDefinitionId, controlTypeId, tabIndex, GetNull(XML), visible, isTitle, dataConnectionId));
		}
        
		public override void FieldDefinitionUpdate(Int32 fieldDefinitionId, string title, string cssClass, bool search, string tooltip, bool required, string sourceField, Int32 formDefinitionId, Int32 controlTypeId, string XML, bool visible, bool isTitle, Int32 dataConnectionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionUpdate", fieldDefinitionId, title, GetNull(cssClass), search, GetNull(tooltip), required, sourceField, formDefinitionId, controlTypeId, GetNull(XML), visible, isTitle, dataConnectionId);
		}

		public override void FieldDefinitionDeleteAllFieldDefinitions(Int32 formDefinitionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionDeleteAllFieldDefinitions", formDefinitionId);
		}

		public override void FieldDefinitionDelete(Int32 fieldDefinitionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionDelete", fieldDefinitionId);
		}
        
		public override IDataReader FieldDefinitionGet(Int32 fieldDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionGet", fieldDefinitionId);
		}
        
		public override IDataReader FieldDefinitionByControlType(Int32 controlTypeId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionByControlType", controlTypeId);
		}
        
		public override IDataReader FieldDefinitionByFormDefinition(Int32 formDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionByFormDefinition", formDefinitionId);
		}
        
		public override IDataReader FieldDefinitionGetFieldDefinitionControlTypes(Int32 formDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFieldDefinitionGetFieldDefinitionControlTypes", formDefinitionId);
		}
		#endregion

		#region Data Access methods implementation for cbLabels
        
		public override Int32 LabelAdd(string shortName, Int32 moduleId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbLabelsAdd", shortName, moduleId));
		}
        
		public override void LabelUpdate(Int32 labelId, string shortName, Int32 moduleId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbLabelsUpdate", labelId);
		}
        
		public override void LabelDelete(Int32 labelId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbLabelsDelete", labelId);
		}
        
		public override IDataReader LabelGet(Int32 labelId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbLabelsGet", labelId);
		}

		public override IDataReader LabelGetByModule(Int32 moduleId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbLabelsGetByModule", moduleId);
		}

		public override IDataReader LabelGetAll() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbLabelsGetAll");
		}
		#endregion
        
		#region Data Access methods implementation for cbFormDataConnections
        
		public override void FormDataConnectionsAdd(Int32 formDefinitionId, Int32 dataConnectionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFormDataConnectionsAdd", formDefinitionId, dataConnectionId);
		}
        
		public override void FormDataConnectionsUpdate(Int32 formDefinitionId, Int32 dataConnectionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFormDataConnectionsUpdate", formDefinitionId, dataConnectionId);
		}
        
		public override void FormDataConnectionsDelete(Int32 formDefinitionId, Int32 dataConnectionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFormDataConnectionsDelete", formDefinitionId, dataConnectionId);
		}

		public override void FormDataConnectionsDeleteByFormDefinition(Int32 formDefinitionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFormDataConnectionsDeleteByFormDefinition", formDefinitionId);
		}

		public override IDataReader FormDataConnectionsGet(Int32 formDefinitionId, Int32 dataConnectionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDataConnectionsGet", formDefinitionId, dataConnectionId);
		}
        
		public override IDataReader FormDataConnectionsByDataConnection(Int32 dataConnectionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDataConnectionsByDataConnection", dataConnectionId);
		}
        
		public override IDataReader FormDataConnectionsByFormDefinition(Int32 formDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDataConnectionsByFormDefinition", formDefinitionId);
		}
		#endregion
        
		#region Data Access methods implementation for cbFormDefinition
        
		public override Int32 FormDefinitionAdd(string title, string css) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbFormDefinitionAdd", title, css));
		}
        
		public override void FormDefinitionUpdate(Int32 formDefinitionId, string title, string css) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFormDefinitionUpdate", formDefinitionId, title, css);
		}
        
		public override void FormDefinitionDelete(Int32 formDefinitionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbFormDefinitionDelete", formDefinitionId);
		}
        
		public override IDataReader FormDefinitionGet(Int32 formDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDefinitionGet", formDefinitionId);
		}

		public override IDataReader FormDefinitionGetByTitle(string formTitle) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDefinitionGetFormByTitle", formTitle);
		}

		public override IDataReader FormDefinitionGetAllFormDefinition() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDefinitionGetAllFormDefinition");
		}
        
		public override IDataReader FormDefinitionGetFormDefinitionDataConnections() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDefinitionGetFormDefinitionDataConnections");
		}
        
		public override IDataReader FormDefinitionGetFormDefinitionFieldDefinition() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbFormDefinitionGetFormDefinitionFieldDefinition");
		}
		#endregion
        
		#region Data Access methods implementation for cbMetaData
        
		public override Int32 MetaDataAdd(string title, string PKValue, string status, Int32 taxonomyId, Int32 formDefinitionId, DateTime scheduleDate, Int32 dataConnectionID, Int32 userID, Int32 portalID, DateTime  publishDate, DateTime  expireDate, DateTime  CreationDate) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbMetaDataAdd", title, PKValue, status, GetNull(taxonomyId), formDefinitionId, GetNull(scheduleDate), GetNull(CreationDate), dataConnectionID, GetNull(userID), portalID, GetNull(publishDate), GetNull(expireDate)));
		}
        
		public override void MetaDataUpdate(Int32 metaDataId, string title, string pkValue, string status, Int32 taxonomyId, Int32 formDefinitionId, DateTime scheduleDate, DateTime CreationDate, Int32 dataConnectionID, Int32 userID, Int32 portalID, DateTime publishDate, DateTime expireDate) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataUpdate", metaDataId, title, pkValue, status, GetNull(taxonomyId), formDefinitionId, GetNull(scheduleDate), GetNull(CreationDate), dataConnectionID, GetNull(userID), portalID, GetNull(publishDate), GetNull(expireDate));
		}
        
		public override void MetaDataDelete(Int32 metaDataId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataDelete", metaDataId);
		}
        
		public override void MetaDataDeleteSchedule(Int32 metaDataId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataDeleteSchedule", metaDataId);
		}

		public override IDataReader MetaDataGet(Int32 metaDataId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGet", metaDataId);
		}
		
		public override IDataReader MetaDataGetAddingHit(string guid, string userRoles) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetAddingHit", guid, userRoles);
		}

		public override IDataReader MetaDataByPKValue(string pkValue, string userRoles)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataByPKValue", pkValue, userRoles);
		}
        
		public override IDataReader MetaDataByFormDefinition(Int32 portalId, Int32 formId, Int32 rowCount, string where, string orderBy, string userRoles)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataByFormDefinition", portalId, formId, rowCount, where, orderBy, userRoles);
		}
        
		public override IDataReader MetaDataByTaxonomy(Int32 portalId, Int32 formId, Int32 taxonomyId, Int32 rowCount, string where, string orderBy, string userRoles)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataByTaxonomy", portalId, formId, taxonomyId, rowCount, where, orderBy, userRoles);
		}

		public override IDataReader MetaDataXRefByTaxonomy(Int32 portalId, Int32 formId, Int32 taxonomyId, Int32 rowCount, string where, string orderBy, string userRoles)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataXRefByTaxonomy", portalId, formId, taxonomyId, rowCount, where, orderBy, userRoles);
		}
        
		public override IDataReader MetaDataByPortal(Int32 portalID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataByPortal", portalID);
		}
        
		public override IDataReader MetaDataByUser(Int32 userID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataByUser", userID);
		}
        
		public override IDataReader MetaDataGetAllMetaData(Int32 PortalID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetAllMetaData", PortalID);
		}

		public override IDataReader MetaDataGetMostPopularItems(Int32 portalId, Int32 formId, Int32 rowCount, bool onlyPublished, string userRoles) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetMostPopularItems", portalId, formId, rowCount, onlyPublished, userRoles);
		}

		public override IDataReader MetaDataGetMetaDataByUser(Int32 PortalID, Int32 UserID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetMetaDataByUser", PortalID, UserID);
		}
        
		public override IDataReader MetaDataGetMoreRecentApprovedContent(Int32 portalId, Int32 formId, string userRoles) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetMoreRecentApprovedContent", portalId, formId, userRoles);
		}

		public override IDataReader MetaDataPublishScheduledContent(Int32 PortalID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataPublishScheduledContent", PortalID);
		}

		public override IDataReader MetaDataGetScheduledContent(Int32 portalID, Int32 moduleID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetScheduledContent", portalID, moduleID);
		}
        
		public override IDataReader MetaDataGetNotApprovedMetaDataByUser(Int32 PortalID, DateTime CreationDate, Int32 UserID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetNotApprovedMetaDataByUser", PortalID, CreationDate, UserID);
		}
        
		public override IDataReader MetaDataGetWorkingMetaDataByUser(Int32 PortalID, Int32 UserID) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataGetWorkingMetaDataByUser", PortalID, UserID);
		}
		#endregion
        
		#region Data Access methods implementation for cbMetaDataLabel

		public override Int32 MetaDataLabelAdd(Int32 metaDataId, Int32 labelId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbMetaDataLabelAdd", metaDataId, labelId));
		}

		public override void MetaDataLabelDelete(Int32 metaDataId, Int32 labelId)
		{
			ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbMetaDataLabelDelete", metaDataId, labelId);
		}

		public override void MetaDataLabelDeleteByLabel(Int32 labelId)
		{
			ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbMetaDataLabelDeleteByLabel", labelId);
		}
		#endregion

		#region Data Access methods implementation for cbMetaDataTask
        
		public override Int32 MetaDataTaskAdd(Int32 taskOrder, DateTime startDate, string status, string title, DateTime finishDate, Int32 metaDataId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskAdd", taskOrder, GetNull(startDate), status, title, GetNull(finishDate), metaDataId));
		}
        
		public override void MetaDataTaskUpdate(Int32 metaDataTaskId, Int32 taskOrder, DateTime startDate, string status, string title, DateTime finishDate, Int32 metaDataId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskUpdate", metaDataTaskId, taskOrder, GetNull(startDate), status, title, GetNull(finishDate), metaDataId);
		}
        
		public override void MetaDataTaskDelete(Int32 metaDataTaskId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskDelete", metaDataTaskId);
		}

		public override void MetaDataTaskDeleteAll(Int32 metaDataId) {
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskDeleteAll", metaDataId);
		}
		
		public override IDataReader MetaDataTaskGet(Int32 metaDataTaskId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskGet", metaDataTaskId);
		}
        
		public override IDataReader MetaDataTaskByTaskOwner(Int32 taskOwnerId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskByTaskOwner", taskOwnerId);
		}
        
		public override IDataReader MetaDataTaskGetMetaDataTasksByOwner(Int32 TaskOwnerId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskGetMetaDataTasksByOwner", TaskOwnerId);
		}

		public override IDataReader MetaDataTaskGetMetaDataTasksByOwnerAndModule(Int32 taskOwnerId, Int32 moduleId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskGetMetaDataTasksByOwnerAndModule", taskOwnerId, moduleId);
		}

		
		#endregion
		
		
		#region Data Access methods implementation for cbMetaDataEvent
        
		public override Int32 MetaDataEventAdd(Int32 metadataId, string eventType, string eventDescription, string eventDetails, int userId, DateTime eventDate)
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbMetaDataEventsAdd", metadataId, eventType, eventDescription, eventDetails, userId, eventDate));
		}

		public override IDataReader MetaDataEventGet(Int32 eventId)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataEventsGet", eventId);
		}

		public override IDataReader MetaDataEventGetAll()
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataEventsGetAll");
		}

		public override IDataReader MetaDataEventGetByMetaDataId(Int32 metaDataTaskId)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataEventsGetByMetaDataId", metaDataTaskId);
		}

		
		#endregion
		
				
		#region Data Access methods implementation for cbTaskOwner
        
		public override Int32 TaskOwnerAdd(Int32 ownerId, string ownerType, Int32 taskId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbTaskOwnerAdd", ownerId, ownerType, taskId));
		}
        
		public override void TaskOwnerUpdate(Int32 taskOwnerId, Int32 ownerId, string ownerType, Int32 taskId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTaskOwnerUpdate", taskOwnerId, ownerId, ownerType, taskId);
		}
        
		public override void TaskOwnerDelete(Int32 taskOwnerId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTaskOwnerDelete", taskOwnerId);
		}
        
		public override IDataReader TaskOwnerGet(Int32 taskOwnerId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTaskOwnerGet", taskOwnerId);
		}
        
		public override IDataReader TaskOwnerGetTasksByOwner(Int32 OwnerId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTaskOwnerGetTasksByOwner", OwnerId);
		}

		public override IDataReader TaskOwnerGetTaskOwners(Int32 taskId)  
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTaskOwnerGetTaskOwners", taskId);
		}

		public override IDataReader MetaDataTaskOwnerGetNext(Int32 taskId)  
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskOwnerGetNextTaskOwners", taskId);
		}
		
		#endregion
        
		#region Data Access methods implementation for cbTasks
        
		public override Int32 TasksAdd(string title, string description, Int32 workflowId, Int32 taskOrder) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbTasksAdd", title, description, workflowId, taskOrder));
		}
        
		public override void TasksUpdate(Int32 taskId, string title, string description, Int32 workflowId, Int32 taskOrder) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTasksUpdate", taskId, title, description, workflowId, taskOrder);
		}
        
		public override void TasksDelete(Int32 taskId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTasksDelete", taskId);
		}

		public override void DeleteWorkflowTasks(Int32 workflowId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTasksDeleteByWorkflow", workflowId);
		}
		
		public override IDataReader TasksGet(Int32 taskId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTasksGet", taskId);
		}

		public override IDataReader TasksByWorkflow(Int32 workflowId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTasksByWorkflow", workflowId);
		}
        
		public override IDataReader TasksGetTasksByWorkflow(Int32 WorkflowId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTasksGetTasksByWorkflow", WorkflowId);
		}
		#endregion

		#region Data Access methods implementation for cbMetaDataTaskOwner

		public override Int32 MetaDataTaskOwnerAdd(Int32 ownerId, string ownerType, Int32 metaDataTaskId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskOwnerAdd", ownerId, ownerType, metaDataTaskId));
		}

		public override void MetaDataTaskOwnerUpdate(Int32 metaDataTaskOwnerId, Int32 ownerId, string ownerType, Int32 metaDataTaskId)
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskOwnerUpdate", metaDataTaskOwnerId, ownerId, ownerType, metaDataTaskId);
		}
		public override void MetaDataTaskOwnerDeleteAll(Int32 metaDataTaskId)
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskOwnerDeleteAll", metaDataTaskId);
		}
		public override void MetaDataTaskOwnerDelete(Int32 metaDataTaskOwnerId)
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskOwnerDelete", metaDataTaskOwnerId);
		}
		public override IDataReader MetaDataTaskOwnerGet(Int32 metaDataTaskOwnerId)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskOwnerGet", metaDataTaskOwnerId);
		}
		public override IDataReader MetaDataTaskGetCurrent(Int32 metaDataTaskId)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskGetCurrent", metaDataTaskId);
		}
		public override IDataReader MetaDataTaskGetNext(Int32 metaDataId, Int32 taskOrder)   
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbMetaDataTaskGetNext", metaDataId, taskOrder);
		}

		#endregion

		#region Data Access methods implementation for cbTaxonomy
        
		public override Int32 TaxonomyAdd(string title, string description, Int32 parentId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbTaxonomyAdd", GetNull(title), GetNull(description), GetNull(parentId)));
		}
        
		public override void TaxonomyUpdate(Int32 taxonomyId, string title, string description, Int32 parentId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTaxonomyUpdate", taxonomyId, GetNull(title), GetNull(description), GetNull(parentId));
		}
        
		public override void TaxonomyDelete(Int32 taxonomyId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTaxonomyDelete", taxonomyId);
		}
        
		public override IDataReader TaxonomyGet(Int32 taxonomyId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTaxonomyGet", taxonomyId);
		}
        
		public override IDataReader TaxonomyByTitle(string taxonomyTitle, Int32 parentId)
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTaxonomyByTitle", taxonomyTitle, parentId);
		}
        
		public override IDataReader TaxonomyGetTaxonomyRoot() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTaxonomyGetTaxonomyRoot");
		}
        
		public override IDataReader TaxonomyGetTaxonomySubTree(Int32 ParentId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTaxonomyGetTaxonomySubTree", ParentId);
		}
		#endregion
        
		#region Data Access methods implementation for cbTemplateDefinition
        
		public override Int32 TemplateDefinitionAdd(string templateName, string body, Int32 formDefinitionId) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbTemplateDefinitionAdd", GetNull(templateName), GetNull(body), formDefinitionId));
		}
        
		public override void TemplateDefinitionUpdate(Int32 templateDefinitionId, string templateName, string body, Int32 formDefinitionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTemplateDefinitionUpdate", templateDefinitionId, GetNull(templateName), GetNull(body), formDefinitionId);
		}
        
		public override void TemplateDefinitionDelete(Int32 templateDefinitionId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbTemplateDefinitionDelete", templateDefinitionId);
		}
        
		public override IDataReader TemplateDefinitionGet(Int32 templateDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTemplateDefinitionGet", templateDefinitionId);
		}

		public override IDataReader TemplateDefinitionGetByName(string templateName) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTemplateDefinitionGetByName", templateName);
		}

		public override IDataReader TemplateDefinitionGetByFormId(Int32 formDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTemplateDefinitionByFormDefinition", formDefinitionId);
		}
        
		public override IDataReader TemplateDefinitionByModuleId(Int32 FormDefinitionId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbTemplateDefinitionByModuleId", FormDefinitionId);
		}
		#endregion
        
		#region Data Access methods implementation for cbWorkflow
        
		public override Int32 WorkflowAdd(string title, string description) 
		{
			return Convert.ToInt32(ExecuteScalar(DatabaseOwner + ObjectQualifier + "cbWorkflowAdd", title, GetNull(description)));
		}
        
		public override void WorkflowUpdate(Int32 workflowId, string title, string description) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbWorkflowUpdate", workflowId, title, GetNull(description));
		}
        
		public override void WorkflowDelete(Int32 workflowId) 
		{
			ExecuteNonQuery(DatabaseOwner + ObjectQualifier + "cbWorkflowDelete", workflowId);
		}
        
		public override IDataReader WorkflowGet(Int32 workflowId) 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbWorkflowGet", workflowId);
		}
        
		public override IDataReader WorkflowGetAllWorkflows() 
		{
			return ExecuteReader(DatabaseOwner + ObjectQualifier + "cbWorkflowGetAllWorkflows");
		}
		#endregion
		
		

		#endregion
	}
}
